
package com.hazelcast.internal.config.override;

import java.util.Collections;
import java.util.Map;

/**
 * A {@link ConfigProvider} extracting config entries from environment variables.
 */
class EnvConfigProvider implements ConfigProvider {

    private final EnvVariablesConfigParser envVariablesConfigParser;
    private final Map<String, String> envVariables;

    EnvConfigProvider(EnvVariablesConfigParser envVariablesConfigParser, Map<String, String> envVariables) {
        this.envVariablesConfigParser = envVariablesConfigParser;
        this.envVariables = envVariables;
    }

    @Override
    public Map<String, String> properties() {
        return Collections.unmodifiableMap(envVariablesConfigParser.parse(envVariables));
    }

    @Override
    public String name() {
        return "environment variables";
    }
}
